<template>
  <div class="demo">
    <div class="window">
      <header class="title-bar">
        <div class="left">
          <van-icon v-if="currentRoute.path != '/menu'" class="back" name="arrow-left" @click="$router.back()" />
        </div>
        <span class="title">Zui</span>
        <div class="menus"></div>
      </header>
      <main class="main">
        <router-view></router-view>
      </main>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const activeMenuName = ref()
function onMenuSelected(name) {
  activeMenuName.value = name
}

//***** 路由状态 *****/
const router = useRouter()
const currentRoute = ref(router.currentRoute)
</script>

<style scoped lang="scss">
.demo {
  height: 100%;
  width: 100%;
  padding: 48px;
  overflow: auto;
  box-sizing: border-box;
  .window {
    width: 390px;
    height: 100%;
    overflow: hidden;
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: 0px 4px 12px 2px #f0f0f0;
    background-color: #ffffff;
    .title-bar {
      display: flex;
      text-align: center;
      line-height: 64px;
      font-weight: bold;
      font-size: 18px;
      .left {
        width: 50px;
        overflow: hidden;
        .back {
          cursor: pointer;
          padding: 20px;
        }
      }
      .title {
        flex: 1;
      }
      .menus {
        width: 50px;
      }
    }
    .main {
      background-color: #f8f8f8;
      height: calc(100% - 64px);
      overflow: auto;
    }
  }
}
@media screen and (max-width: 438px) {
  .demo {
    padding: 0;
    .window {
      width: 100%;
      height: 100%;
      overflow: hidden;
      margin: 0 auto;
      border-radius: 12px;
      box-shadow: 0px 4px 12px 2px #f0f0f0;
      .title-bar {
        display: none;
      }
      .main {
        height: 100%;
      }
    }
  }
}
</style>
